package org.grow.score.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.grow.common.deal.DealBillDto;
import org.grow.common.deal.DealService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Author: xwg
 * @CreateDate: 21-8-16
 */

@DubboService
public class DealBillService implements DealService {
    @Autowired
    private ObjectMapper objectMapper;
    @Override
    public Boolean deal(DealBillDto dealBillDto) {
        if (dealBillDto.getAmount()<0){
            throw new RuntimeException("交易分数不能小于0");
        }
        try {
            System.out.println(objectMapper.writeValueAsString(dealBillDto));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        System.out.println("进入数据库维护");
        return true;
    }
}
